module.exports = function ($scope, $state, $resource, $modal, toaster) {
	$scope.myKeyup = function (e) {
		//IE 编码包含在window.event.keyCode中，Firefox或Safari 包含在event.which中
		var keycode = window.event ? e.keyCode : e.which;
		if (keycode == 13) {
			$scope.loadlist();
		}
	};
	$scope.pageInfo = {};
	$scope.pageInfo.pageNo = 1;		//当前页码
	$scope.pageInfo.pageSize = 10;	//每页显示几条
	$scope.pageInfo.totalItems = 0;	//总条数
	//列表
	$scope.loadlist = function () {
		$resource('/api/as/mc/shopproduct/findBoomList', {}, {}).save($scope.pageInfo, function (res) {
			if (res.errcode === 0) {
				$scope.beanList = res.data.results;
				$scope.pageInfo.totalItems = res.data.totalRecord;
			} else {
				toaster.error({ title: '', body: res.errmsg });
			}
		});
		$resource('/api/as/mc/shopproduct/findMyProductNoPageList', {}, {}).save({}, function (res) {
			if (res.errcode === 0) {
				$scope.ProductList = res.data;
			} else {
				toaster.error({ title: '', body: res.errmsg });
			}
		});
	}

	$scope.loadlist();

	



	//发送
    $scope.add = function (bean) {
			$resource('/api/as/mc/shopproduct/insertBoomProduct', {}, {}).save(bean, function (res) {
				if (res.errcode === 0) {
					$scope.loadlist();
				} else {
					toaster.error({ title: '', body: res.errmsg });
				}
			});
	}




	//删除
	$scope.delete = function (bean) {
		if (confirm('确认删除此条记录吗？') == true) {
			$resource('/api/as/mc/shopproduct/updateBoomdel', {}, {}).save(bean, function (res) {
				if (res.errcode === 0) {
					$scope.loadlist();
				} else {
					toaster.error({ title: '', body: res.errmsg });
				}
			});
		}
	}

};